#include<iostream>
#include<string>
#include<queue>
#include<pthread.h>
template<typename T>
const static int defaultcap=5;
class BlockQueue
{
private:
bool Isfull()
{
    return _block_queue.size()==_max_cap;
}
public:
    BlockQueue(int cap=default cap):_max_cap(cap)
    {
        pthread_mutex_init(&_mutex,nullptr);
        pthread_cond_init(&_p_cond,nullptr);

    }
    void Equeue(const T&in)
    {
        pthread_mutex_lock(&_mutex);
        if(Isfull())
        {
            //这里需要等待；生产者不能生产了
            //当他被唤醒时，不久是还在临界区吗
            pthread_cond_wait(&_p_cond, &_mutex);
            //这里为的就是顺序型 

        }
        pthread_mutex_unlock(&_mutex);

    }
    void Pop(T *out)
    {
        
    }
    ~BlockQueue()
    {
        pthread_mutex_destroy(&_mutex);
        pthread_cond_destroy(&_p_cond);
    }

private:
    std::queue<T> _block_queue;
    pthread_mutex_t _mutex;
    int _max_cap;
    prthread_cond_t _p_cond;
}